{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "单面\n",
      "双面\n"
     ]
    }
   ],
   "source": [
    "# 结构型模式\n",
    "class UsbTypeA():\n",
    "    def getName(self):\n",
    "        return \"TypeA接口\"\n",
    "    \n",
    "    def oneFace(self):\n",
    "        return \"单面\"\n",
    "    \n",
    "class UsbTypeC():\n",
    "    def getName(self):\n",
    "        return \"TypeC接口\"\n",
    "    \n",
    "    def doubleFace(self):\n",
    "        return \"双面\"\n",
    "\n",
    "# 适配器\n",
    "class Adapter(UsbTypeC):\n",
    "    def oneFace(self):\n",
    "        return self.doubleFace()\n",
    "\n",
    "iface1 = UsbTypeA()\n",
    "print(iface1.oneFace())\n",
    "iface2 = Adapter()\n",
    "print(iface2.oneFace())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.10.7 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.0"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
